import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2023-12-03
 * Time:10:08
 */
public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {1,4,2,6,8,9,7,5,3,0};
        Sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    private static void Sort(int[] arr) {
        for(int i = 0;i<arr.length-1;i++) {
            int flg = 0;
            for(int j = 0;j<arr.length-i-1;j++) {
                if(arr[j] > arr[j+1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                    flg = 1;
                }
            }
            if(flg == 0) {
                break;
            }
        }
    }
}
